Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next
Subject: encoding and decoding base64 file issue
Feedback Type: Problem
Product Area: Domino Server
Technical Area: Application Development
Platform: Windows
Release: 8.5.3
Reproducible: Always

Hi all,

running into an issue haven't seen this before where content during the encoding and decoding of an image looses byte count.

I have an app taking the photo image and sending the file via:

-----------------------
byte[] imageBytes = new byte[(int) imageFile.length()];

inputFile = new RandomAccessFile(imageFile, "r");
inputFile.read(imageBytes);

String base64String = Base64.encodeToString(imageBytes, Base64.DEFAULT);
------------------------


id Base64string goes across the soapenv request
like:

------------------------
var sr = '<?xml version="1.0" encoding="utf-8"?>' +
'<soapenv:Envelope ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' +
'xmlns:urn="urn:DefaultNamespace">'+
'<soapenv:Header/>'+
'<soapenv:Body>' +
'<urn:addNewFileComplex soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
'<daFile xsi:type="urn:lookupAssessmentFile">' +
'<base64File xsi:type="soapenc:base64" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">cid:560948411422</base64File>' +
'<UserName xsi:type="xsd:string">'+uname+'</UserName>' +
'<Password xsi:type="xsd:string">'+pwd+'</Password>' +
'<Seq xsi:type="xsd:string">'+seq+'</Seq>' +
'<noteID xsi:type="xsd:string">'+noid+'</noteID>' +
'<da_incident xsi:type="xsd:string">'+incName+'</da_incident>' +
'<da_incidentid xsi:type="xsd:string">'+incID+'</da_incidentid>' +
'<da_createdon xsi:type="xsd:string">'+dCreated+'</da_createdon>' +
'<fileName xsi:type="xsd:string">'+fileName+'</fileName>' +
--------------------


The web request creates the document and adds the field data and I even get the attachment embedded.

The issue is that if the original jpeg is 59k, I get an image file of 48k in size.

I verify the log on the originating bit count and get 59037 byte stream.

On domino when actions performed via:

----------------
if (tempFile == null)
tempFile = File.createTempFile("Tempfile-", ".b64", new File(getTempDir()));

//System.out.println("received byte count is: "+base64bytes.length);

ByteArrayInputStream in = new ByteArrayInputStream(base64bytes);
FileOutputStream out = new FileOutputStream(tempFile);
BASE64Decoder decoder = new BASE64Decoder();
decoder.decodeBuffer(in, out);
System.out.println("tempfile is: "+tempFile);
System.out.println("tempfile length is: "+base64bytes.length);
in.close();
out.close();
..
--------------------------

base64bytes.length is lower than when it was sent after decoded method is used on the domino server.


Has anyone been able to get the image file re-conformed on the resulting side?

UTF-8 is used and have changed content-type on the soap header to "image/jpg" with no success.

Thanks,

Geoff-


Feedback number WEBB92UNL2 created by ~Martha Breboosilit on 12/10/2012

Status: Open
Comments:





Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS